package scsc.pub.process.dispatch;

import java.util.ArrayList;

import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;

import scsc.pm.DispatchPm;
import scsc.pm.MeetingPm;
import scsc.pub.db.DBManage;
import scsc.pub.exception.UnifyUserException;
import scsc.web.process.data.DispatchData;
import scsc.web.process.data.MeetingData;

public class NumberAction implements ActionHandler {

	public void execute(ExecutionContext executionContext) throws Exception {
		// TODO Auto-generated method stub
		DispatchData data = new DispatchData();
		DispatchPm dispatch = new DispatchPm();
		DBManage dbmanage = new DBManage();
		try {
			data.setProcessInstanceId(executionContext.getProcessInstance()
					.getId());
			ArrayList al = dispatch.selectDispatchs(dbmanage, data);
			dbmanage.begin();
			if (al != null && al.size() == 1) {
				DispatchData dispatchData = (DispatchData) al.get(0);
				dispatchData.setState("1");
				dispatch.modifyDispatch(dbmanage, dispatchData);
			}
			dbmanage.commit();
			dbmanage.close();
		} catch (UnifyUserException e) {
			dbmanage.rollback();
			dbmanage.close();
		}
	}

}
